﻿package app.view.components.guiDima.switchContent 
{
	import app.view.components.guiDima.switchContent.SwitchContentDBase;
	
	/**
	 * Контейнер перелистывания для персон
	 * @author Dmitryi_Koruagin, icq:585466579, dmitryikoruagin@yandex.ru
	 */
	public class SwitchContentPersonalDBase extends SwitchContentDBase
	{
		// app.view.components.guiDima.switchContent.SwitchContentPersonalDBase
		
		public var bgd:Sprite;
		//	private
		
		//	const
		
		//	CONSTRUCTOR
		public function SwitchContentPersonalDBase() 
		{
			super();
		}
		
		//	METHODS
		//	private
		override public function init():void
		{
			_contentWidth = bgd.width;
			_contentHeight = bgd.height;
			super.init();
			bgd.visible = false;
			
			gapNarrow = 30;
			//setBoundsContent(contentTextBgd.width, contentTextBgd.height)
		}
		
		override public function change():void 
		{
			////trace('change SwitchContentDBase: !!!',_currentPageID);
			
			if ( _currentSection ) 
			{
				_currentSection.destroy();
			};
			
			_currentSection = new ContentHistoryD(bgd.width, bgd.height);
			if ( !_currentSection ) return;
			// инициализируем
			_currentSection.alpha = 0;
			_currentSection.open();
			_currentSection.data = _data[_currentPageID];
			addChild(_currentSection);
		};
		
		override public function destroy():void
		{
			try 
			{
				if (_currentSection) 
				{
					_currentSection.onDestroy();
					removeChild(_currentSection);
				}
			}catch (err:Error)
			{
				trace('e ');
			}
			
			super.destroy();
		}
		
		//	GETTERS/SETTERS
		override public function get data():Array { return _data; };
		
		override public function set data(value:Array):void 
		{
			super.data = value;
			
			// получили массив устанавливаем первый страницу
			//trace('data tyt');
			if (_data!=null) 
			{
				change();
			}
			
		};
	}

}